import { _decorator, Component, Label, Node, Tween, tween, UIOpacity, Vec3 } from 'cc';
import { UIMgr } from '../Mgr/UIMgr';
import { AssetList } from '../Global';
const { ccclass, property } = _decorator;

@ccclass('TopPrompt')
/**
 * 顶部提示
 */
export class TopPrompt extends Component {

    @property(Node)
    private Box: Node = null;

    @property(Label)
    private Content: Label = null;

    public UpdateContent(content: string) {
        this.Content.string = content;

        let box_opciaty: UIOpacity = this.Box.getComponent(UIOpacity);

        Tween.stopAllByTarget(this.Box);
        Tween.stopAllByTarget(box_opciaty);

        box_opciaty.opacity = 255;
        this.Box.setPosition(new Vec3(0, 0, 0))

        tween(box_opciaty).to(1, { opacity: 0 }).start();
        tween(this.Box).to(1, { position: new Vec3(0, 100) }).call(() => {
            UIMgr.Instance.HideTop(AssetList.Top.Prompt);
        }).start();

    }

}


